//@author A0083782W
//The settings class decide how the rest of the program display or
//read time/date. It also stores many other user specification.
//Please remember to update them accordingly after you have added into the setting class.
//
//Setting is singleton, it is therefore used in a different way from the common type of class.
//You can never assign, create or copy objects of this class.
//It must be accessed or modified using pointers as the API given below.
//
//How to use?
//If you want to just read the settings, use Settings::get(), do the following:
//ReadSettingPtr mySetting = &Settings::get();
//E.g. Want to read date format?
//?? = mySetting->getDateDisplayFormat();
//If you want to read and/or write the settings, use this instead:
//WriteSettingPtr mySetting = &Settings::get();
//Then you are able to do the following:
//E.g Want to set date format?
//mySetting->setDateDisplayFormat(DateDisplayFormat::YYMMDD);

#pragma once
#include <string>
#include <fstream>
#include <vector>
#include "CommonDataType.h"

using std::vector;
using std::string;
using std::fstream;
using std::endl;
using std::getline;
using std::ios;
using namespace CommonDataType;

enum class DateDisplayFormat {
	DDMMYYYY = 0,
	DDMMYY = 1,
	YYYYMMDD = 2,
	YYMMDD = 3,
	MMDDYYYY = 4,
	MMDDYY = 5
};

enum class TimeDisplayFormat {
	AM_PM = 0,
	TWENTY_FOUR = 1
};

enum class DisplayOrder {
	HIGHT_TO_LOW = 0,
	LOW_TO_HIGH = 1,
};

class Settings {
public:	
	~Settings ();
	static Settings& get(); //put the real constructor inside here.
	
	DateDisplayFormat getDateDiplayFormat () const;
	void setDateDisplayFormat (DateDisplayFormat newFormat);
	TimeDisplayFormat getTimeDisplayFormat () const;
	void setTimeDisplayFormat (TimeDisplayFormat newFormat);
	DisplayOrder getTimeListingOrder() const;
	void setTimeListingOrder (DisplayOrder newOrder);
	void saveSetting();
	void readSetting();

private:
	DateDisplayFormat _dateDisplayFormat;
	TimeDisplayFormat _timeDisplayFormat;
	DisplayOrder _timeListingOrder;

	static con_str FILENAME;
	static bool hasRun; 
	
	Settings ();	//Kill constructor
	Settings (const Settings&); //Kill copy constructor
	Settings& operator= (const Settings&); //Kill assignment operation
};

typedef Settings * const WriteSettingPtr;
typedef Settings const * const ReadSettingPtr;